#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include <string.h>
#include "dominion/dominion.h"
#include "dominion/dominion_helpers.h"
#include "dominion/rngs.h"
#include "dominion/interface.h"

/* testing adventurer card*/

int cardEffect(int card, int choice1, int choice2, int choice3, struct gameState *state, int handPos, int *bonus);

int main (int argc, char * argv[])
{
	/*modified from the initialization in the provided testUpdateCoins.c file */
    int seed = 1000;
    int numPlayer = 2;
    int k[10] = {adventurer, council_room, feast, gardens, mine
               , remodel, smithy, village, baron, great_hall};
	int r;
	int bonus = 0;
	
	/* test one -- to see if same amount of cards are in deck after switching out treasure cards */
	struct gameState test_one;
    memset(&test_one, 23, sizeof(struct gameState));   // clear the game state
    r = initializeGame(numPlayer, k, seed, &test_one); // initialize a new game
	
	int totalcount = test_one.deckCount[0] + test_one.discardCount[0] + test_one.handCount[0];
	
	cardEffect(adventurer, 0, 0, 0, &test_one, 0, &bonus);
	
	int after_totalcount = test_one.deckCount[0] + test_one.discardCount[0] + test_one.handCount[0];
	
	if (after_totalcount == totalcount)
		printf("Adventurer test: PASS when testing to see if the same amount of cards are in the deck after switching out treasure cards. \n");
	else
		printf("Adventurer test: FAIL when testing to see if the same amount of cards are in the deck after switching out treasure cards. \n");
	
	/* test two -- to see if coins have been added */
	struct gameState test_two;
    memset(&test_two, 23, sizeof(struct gameState));   // clear the game state
    r = initializeGame(numPlayer, k, seed, &test_two); // initialize a new game
	
	int coins_before = test_two.coins;
	
	cardEffect(adventurer, 0, 0, 0, &test_two, 0, &bonus);
	
	int coins_after = test_two.coins;
	
	if (coins_after > coins_before)
		printf("Adventurer test: PASS when testing to see if coins have been added to current player's round. \n");
	else
		printf("Adventurer test: FAIL when testing to see if coins have been added to current player's round. \n");
	
	/* test three -- to see if two cards have been added to hand */
	struct gameState test_three;
	memset(&test_three, 23, sizeof(struct gameState));   // clear the game state
	r = initializeGame(numPlayer, k, seed, &test_three); // initialize a new game
	
	int before_handcount = test_one.handCount[0];
	
	cardEffect(adventurer, 0, 0, 0, &test_three, 0, &bonus);
	
	int after_handcount = test_one.handCount[0];
	
	if (after_handcount == before_handcount + 2)
		printf("Adventurer test: PASS when testing to see if 2 cards have been added to hand. \n");
	else
		printf("Adventurer test: FAIL when testing to see if 2 cards have been added to hand. \n");
		
	return 0;
}